package com.kr.weitao.util;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by yanyadong on 2016/12/28.
 */
public class DateSwitchUtil {

    public  static  ArrayList<HashMap<String,Object>> switchYequal(String keyY,String keyM,String keyD,String startdate,String enddate){

        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();

        /**
         *
         * 年份相等的情况
         *
         */
        String[] start=startdate.split("-");
        String[] end=enddate.split("-");
        int startY=Integer.parseInt(start[0]);
        int startM=Integer.parseInt(start[1]);
        int  startD=Integer.parseInt(start[2]);
        int  endY=Integer.parseInt(end[0]);
        int  endM=Integer.parseInt(end[1]);
        int  endD=Integer.parseInt(end[2]);


        HashMap<String,Object> map=new HashMap<String, Object>();
        HashMap<String,Object> map_AND=new HashMap<String, Object>();

        if(endM-startM>1) {
            String stM="";
            String  enM="";
            int stm;
            int enm;
            map.put(keyY, startY);
            //判断前面是否加"0"
            if(startM+1<10){
                stm=startM+1;
                stM="0"+stm;
            }else{
                stm=startM+1;
                stM=stm+"";
            }
            if(endM-1>=10){
                enm=endM-1;
                enM=enm+"";
            }else{
                enm=endM-1;
                enM="0"+enm;
            }

            map.put(keyM, "[" + stM + " TO " + enM + "]");
            map_AND.put("AND", map);
            //添加到list
            list.add(map_AND);
        }

        HashMap<String,Object> map1=new HashMap<String, Object>();
        HashMap<String,Object> map2=new HashMap<String, Object>();
        HashMap<String,Object> map1_AND=new HashMap<String, Object>();
        HashMap<String,Object> map2_AND=new HashMap<String, Object>();
        //用and
        map1.put(keyY,startY);
        if(startM<10){
            map1.put(keyM,"0"+startM);
        }else{
            map1.put(keyM,startM);
        }
        if(startD<10){
            map1.put(keyD,"["+"0"+startD+" TO "+"31]");
        }else{
            map1.put(keyD,"["+startD+" TO "+"31]");
        }
        map1_AND.put("AND",map1);
        //添加到list
        list.add(map1_AND);
        //用and
        map2.put(keyY,endY);
        if(endM<10){
            map2.put(keyM,"0"+endM);
        }else{
            map2.put(keyM,endM);
        }
        if(endD<10){
            map2.put(keyD,"[01"+" TO "+"0"+endD+"]");
        }else{
            map2.put(keyD,"[01"+" TO "+endD+"]");
        }

        map2_AND.put("AND",map2);
        list.add(map2_AND);

//  拼接使用：    map_AND  OR  map1_AND   OR   map2_AND

        return   list;

    }


    public  static  ArrayList<HashMap<String,Object>> switchYMequal(String keyY,String keyM,String keyD,String startdate,String enddate){

        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();
        /**
         *
         * 年份,月份都相等的情况   2014-10-21  >>>>2014-10-29
         *
         */
        String[] start=startdate.split("-");
        String[] end=enddate.split("-");
        int startY=Integer.parseInt(start[0]);
        int startM=Integer.parseInt(start[1]);
        int  startD=Integer.parseInt(start[2]);
        int  endY=Integer.parseInt(end[0]);
        int  endM=Integer.parseInt(end[1]);
        int  endD=Integer.parseInt(end[2]);
        HashMap<String,Object> map=new HashMap<String, Object>();
        HashMap<String,Object> map_AND=new HashMap<String, Object>();
        map.put(keyY,startY);
        if(startM<10){
            map.put(keyM,"0"+startM);
        }else{
            map.put(keyM,startM);
        }
        if(startD<10&&endD<10){
            map.put(keyD,"["+"0"+startD+" TO "+"0"+endD+"]");
        }else if(startD<10&&endD>=10){
            map.put(keyD,"["+"0"+startD+" TO "+endD+"]");
        }else if(startD>=10&&endD>=10){
            map.put(keyD,"["+startD+" TO "+endD+"]");
        }
        map_AND.put("AND",map);

        list.add(map_AND);
        return list;
    }


    public  static  ArrayList<HashMap<String,Object>> switchYMgap1(String keyY,String keyM,String keyD,String startdate,String enddate){

        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();

        /**
         *
         *
         * 年份相差等于1的情况   2014 年10月20日 》》》》2015年 12月19日
         *                      2014 年10月20日 》》》》2015年 2月19日
         *
         */

        String[] start=startdate.split("-");
        String[] end=enddate.split("-");
        int startY=Integer.parseInt(start[0]);
        int startM=Integer.parseInt(start[1]);
        int  startD=Integer.parseInt(start[2]);
        int  endY=Integer.parseInt(end[0]);
        int  endM=Integer.parseInt(end[1]);
        int  endD=Integer.parseInt(end[2]);

        //2014年开始的拼接
        HashMap<String,Object> map=new HashMap<String, Object>();
        HashMap<String,Object> map_AND=new HashMap<String, Object>();
        HashMap<String,Object> map1=new HashMap<String, Object>();
        HashMap<String,Object> map1_AND=new HashMap<String, Object>();

        map.put(keyY,startY);
        if(startM<10){
            map.put(keyM,"0"+startM);
        }else{
            map.put(keyM,startM);
        }

        if(startD<10){
            map.put(keyD,"["+"0"+startD+" TO "+"31]");
        }else{
            map.put(keyD,"["+startD+" TO "+"31]");
        }
        map_AND.put("AND",map);

        //添加list
        list.add(map_AND);

        if(12-startM>0){
            map1.put(keyY,startY);
            String sM="";
            int stm;
            if(startM+1<10){
                stm=startM+1;
                sM="0"+stm;
            }else{
                stm=startM+1;
                sM=stm+"";
            }
            map1.put(keyM,"["+sM+" TO "+"12]");
            map1_AND.put("AND",map1);
            //添加list
            list.add(map1_AND);
        }

        //2015年结束的拼接
        HashMap<String,Object> map2=new HashMap<String, Object>();
        HashMap<String,Object> map2_AND=new HashMap<String, Object>();
        HashMap<String,Object> map3=new HashMap<String, Object>();
        HashMap<String,Object> map3_AND=new HashMap<String, Object>();
        map2.put(keyY,endY);
        if(endM<10){
            map2.put(keyM,"0"+endM);
        }else{
            map2.put(keyM,endM);
        }
        //...................................................
        if(endD<10){
            map2.put(keyD,"[01"+" TO "+"0"+endD+"]");
        }else{
            map2.put(keyD,"[01"+" TO "+endD+"]");
        }

        map2_AND.put("AND",map2);

        //添加到list
        list.add(map2_AND);

        if(endM-1>0){
            map3.put(keyY,endY);
            String enM="";
            int enm;
            if(endM-1>=10){
                enm=endM-1;
                enM=enm+"";
            }else{
                enm=endM-1;
                enM="0"+enm;
            }
            map3.put(keyM,"[01"+" TO "+enM+"]");
            map3_AND.put("AND",map3);
            //添加到list
            list.add(map3_AND);
        }

        return   list;

        //拼接字段   map_AND  OR  hashand  OR map_AND_end  OR  hashand_end

    }

    public  static  ArrayList<HashMap<String,Object>>  switchYMmore1(String keyY,String keyM,String keyD,String startdate,String enddate){

        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();
        /**
         *
         * 年份相差大于1的情况     2014 年10月20日 》》》》2018年 12月19日
         *                        2014 年10月20日 》》》》2018年 2月19日
         *
         *
         */

        String[] start=startdate.split("-");
        String[] end=enddate.split("-");
        int startY=Integer.parseInt(start[0]);
        int startM=Integer.parseInt(start[1]);
        int  startD=Integer.parseInt(start[2]);
        int  endY=Integer.parseInt(end[0]);
        int  endM=Integer.parseInt(end[1]);
        int  endD=Integer.parseInt(end[2]);


        //2014年开始的拼接
        HashMap<String,Object> map=new HashMap<String, Object>();
        HashMap<String,Object> map_AND=new HashMap<String, Object>();
        HashMap<String,Object> map1=new HashMap<String, Object>();
        HashMap<String,Object> map1_AND=new HashMap<String, Object>();
        map.put(keyY,startY);

        if(startM<10){
            map.put(keyM,"0"+startM);
        }else{
            map.put(keyM,startM);
        }

        if(startD<10) {
            map.put(keyD, "[" + "0"+startD + " TO " + "31]");
        }else{
            map.put(keyD, "[" + startD + " TO " + "31]");
        }
        map_AND.put("AND",map);

        //添加到list
        list.add(map_AND);

        if(12-startM>0){
            map1.put(keyY,startY);
            String stM="";
            int stm;
            if(startM+1<10){
                stm=startM+1;
                stM="0"+stm;
            }else{
                stm=startM+1;
                stM=stm+"";
            }
            map1.put(keyM,"["+stM+" TO "+"12]");
            map1_AND.put("AND",map1);

            //添加到list
            list.add(map1_AND);
        }

        //2018年结束的拼接
        HashMap<String,Object> map2=new HashMap<String, Object>();
        HashMap<String,Object> map2_AND=new HashMap<String, Object>();
        HashMap<String,Object> map3=new HashMap<String, Object>();
        HashMap<String,Object> map3_AND=new HashMap<String, Object>();
        map2.put(keyY,endY);

        if(endM<10){
            map2.put(keyM,"0"+endM);
        }else{
            map2.put(keyM,endM);
        }
        if(endD<10){
            map2.put(keyD,"[01"+" TO "+"0"+endD+"]");
        }else{
            map2.put(keyD,"[01"+" TO "+endD+"]");
        }
        map2_AND.put("AND",map2);
        //添加到list
        list.add(map2_AND);
        if(endM-1>0){
            map3.put(keyY,endY);
            String enM="";
            int enm;
            if(endM-1>=10){
                enm=endM-1;
                enM=enm+"";
            }else{
                enm=endM-1;
                enM="0"+enm;
            }
            map3.put(keyM,"[01"+" TO "+enM+"]");
            map3_AND.put("AND",map3);
            list.add(map3_AND);
        }

        //年份大于1
        if(endY-startY>1){
            HashMap<String,Object> map4=new HashMap<String, Object>();
            HashMap<String,Object> map4_AND=new HashMap<String, Object>();
            map4.put(keyY,"["+(startY+1)+" TO "+(endY-1)+"]");
            map4_AND.put("AND",map4);
            list.add(map4_AND);
        }

        return  list;
        //拼接字段： map_AND OR hashand  OR  map_AND_end   OR  hashand_end  OR hashyear_and
    }


    /**
     * 当起始日期有一个为空
     */

    public  static  ArrayList<HashMap<String,Object>>  switchYMD(String keyY,String keyM,String keyD,String startdate,String enddate){
        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();

        if(startdate.equals("")&&!enddate.equals("")){

            String[] end=enddate.split("-");
            int  endY=Integer.parseInt(end[0]);
            int  endM=Integer.parseInt(end[1]);
            int  endD=Integer.parseInt(end[2]);
            HashMap<String,Object> map1=new HashMap<>();
            HashMap<String,Object> map1_AND=new HashMap<>();
            map1.put(keyY,endY);
            if(endM<10) {
                map1.put(keyM, "0"+endM);
            }else{
                map1.put(keyM, endM);
            }
            if(endD<10) {
                map1.put(keyD, "[01" + " TO " + "0"+endD + "]");
            }else{
                map1.put(keyD, "[01" + " TO " + endD + "]");
            }
            map1_AND.put("AND",map1);
            list.add(map1_AND);

            if(endM-1>0){
                HashMap<String,Object> map2=new HashMap<>();
                HashMap<String,Object> map2_AND=new HashMap<>();
                map2.put(keyY,endY);
                String enM="";
                int enm;
                if(endM-1>=10){
                    enm=endM-1;
                    enM=enm+"";
                }else{
                    enm=endM-1;
                    enM="0"+enm;
                }
                map2.put(keyM,"[01"+" TO "+enM+"]");
                map2_AND.put("AND",map2);
                //添加到list
                list.add(map2_AND);
            }

            HashMap<String,Object> map3=new HashMap<>();
            HashMap<String,Object> map3_AND=new HashMap<>();
            map3.put(keyY,"[*"+" TO "+(endY-1)+"]");
            map3.put(keyM,"[01 TO 12]");
            map3.put(keyD,"[01 TO 31]");
            map3_AND.put("AND",map3);
            list.add(map3_AND);

        }else if(!startdate.equals("")&&enddate.equals("")){

            String[] start=startdate.split("-");
            int startY=Integer.parseInt(start[0]);
            int startM=Integer.parseInt(start[1]);
            int  startD=Integer.parseInt(start[2]);

            HashMap<String,Object> map1=new HashMap<>();
            HashMap<String,Object> map1_AND=new HashMap<>();
            map1.put(keyY,startY);
            if(startM<10) {
                map1.put(keyM, "0"+startM);
            }else{
                map1.put(keyM, startM);
            }
            if(startD<10){
                map1.put(keyD,"["+"0"+startD+" TO "+"31]");
            }else{
                map1.put(keyD,"["+startD+" TO "+"31]");
            }

            map1_AND.put("AND",map1);
            list.add(map1_AND);
            if(12-startM>0){
                HashMap<String,Object> map2=new HashMap<>();
                HashMap<String,Object> map2_AND=new HashMap<>();
                map2.put(keyY,startY);
                String stM="";
                int stm;
                if(startM+1>=10){
                    stm=startM+1;
                    stM=stm+"";
                }else{
                    stm=startM+1;
                    stM="0"+stm;
                }
                map2.put(keyM,"["+stM+" TO "+"12]");
                map2_AND.put("AND",map2);
                list.add(map2_AND);
            }
            HashMap<String,Object> map3=new HashMap<>();
            HashMap<String,Object> map3_AND=new HashMap<>();
            map3.put(keyY,"["+(startY+1)+" TO "+"*]");
            map3.put(keyM,"[01 TO 12]");
            map3.put(keyD,"[01 TO 31]");
            map3_AND.put("AND",map3);
            list.add(map3_AND);

        }
        return  list;
    }


    /**
     *
     * 对消费日期的转换
     *
     */

    public  static  String  switchConsumeDate(String date){
        //初始化日期
        Calendar calendar = Calendar.getInstance();
        int newdate=Integer.parseInt(date);


        switch (newdate){
            case 3:
                calendar.add(Calendar.MONTH, -3);//得到前3个月
                break;
            case 6:
                calendar.add(Calendar.MONTH, -6);//得到前6个月
                break;
            case 9:
                calendar.add(Calendar.MONTH, -9);//得到前9个月
                break;
            case 12:
                calendar.add(Calendar.MONTH, -12);//得到前12个月
                break;
            case 15:
                calendar.add(Calendar.MONTH, -15);//得到前15个月
                break;
            case 18:
                calendar.add(Calendar.MONTH, -18);//得到前18个月
                break;

        }
        Date formNow3Month = calendar.getTime();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        return  sdf.format(formNow3Month).toString();
    }


    /**
     *
     * @param keyY
     * @param keyM
     * @param keyD  生日转换 不考虑年份
     * @param startdate
     * @param enddate
     * @return
     */
    public  static ArrayList<HashMap<String,Object>> switchBirthDateMD(String keyY, String keyM, String keyD, String startdate, String enddate){

        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();

        /**
         *
         * 不考虑年份比较月,日情况
         *
         */
        String[] start=startdate.split("-");
        String[] end=enddate.split("-");

        //int startBirth=Integer.parseInt(start[1]+start[2]);
        // int endBirth=Integer.parseInt(end[1]+end[2]);
        String startBirth=start[1]+start[2];
        String endBirth=end[1]+end[2];

        //判断生日日期的大小

        if(startBirth.compareTo(endBirth)>0){
            String date="";
            date=startdate;
            startdate=enddate;
            enddate=date;
        }

        String[] startNew=startdate.split("-");
        String[] endNew=enddate.split("-");

        int startM=Integer.parseInt(startNew[1]);
        int  startD=Integer.parseInt(startNew[2]);
        int  endM=Integer.parseInt(endNew[1]);
        int  endD=Integer.parseInt(endNew[2]);


        HashMap<String,Object> map=new HashMap<String, Object>();
        HashMap<String,Object> map_AND=new HashMap<String, Object>();

        if(endM-startM>1) {
            String stM="";
            String  enM="";
            int stm;
            int enm;
            //   map.put(keyY, startY);
            //判断前面是否加"0"
            if(startM+1<10){
                stm=startM+1;
                stM="0"+stm;
            }else{
                stm=startM+1;
                stM=stm+"";
            }
            if(endM-1>=10){
                enm=endM-1;
                enM=enm+"";
            }else{
                enm=endM-1;
                enM="0"+enm;
            }

            map.put(keyM, "[" + stM + " TO " + enM + "]");
            map_AND.put("AND", map);
            //添加到list
            list.add(map_AND);
        }

        HashMap<String,Object> map1=new HashMap<String, Object>();
        HashMap<String,Object> map2=new HashMap<String, Object>();
        HashMap<String,Object> map1_AND=new HashMap<String, Object>();
        HashMap<String,Object> map2_AND=new HashMap<String, Object>();
        //用and
        //   map1.put(keyY,startY);
        if(startM<10){
            map1.put(keyM,"0"+startM);
        }else{
            map1.put(keyM,startM);
        }
        if(startD<10){
            map1.put(keyD,"["+"0"+startD+" TO "+"31]");
        }else{
            map1.put(keyD,"["+startD+" TO "+"31]");
        }
        map1_AND.put("AND",map1);
        //添加到list
        list.add(map1_AND);
        //用and
        //  map2.put(keyY,endY);
        if(endM<10){
            map2.put(keyM,"0"+endM);
        }else{
            map2.put(keyM,endM);
        }
        if(endD<10){
            map2.put(keyD,"[01"+" TO "+"0"+endD+"]");
        }else{
            map2.put(keyD,"[01"+" TO "+endD+"]");
        }

        map2_AND.put("AND",map2);
        list.add(map2_AND);

//  拼接使用：    map_AND  OR  map1_AND   OR   map2_AND

        return   list;

    }


    //


    /**
     *
     * @param keyY
     * @param keyM
     * @param keyD  转换生日日期  当有一个其中为空的情况
     * @param startdate
     * @param enddate
     * @return
     */


    public  static  ArrayList<HashMap<String,Object>>  switchBirthOneMD(String keyY,String keyM,String keyD,String startdate,String enddate){
        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();

        if(startdate.equals("")&&!enddate.equals("")){

            String[] end=enddate.split("-");
            //  int  endY=Integer.parseInt(end[0]);
            int  endM=Integer.parseInt(end[1]);
            int  endD=Integer.parseInt(end[2]);
            HashMap<String,Object> map1=new HashMap<>();
            HashMap<String,Object> map1_AND=new HashMap<>();
            //   map1.put(keyY,endY);
            if(endM<10) {
                map1.put(keyM, "0"+endM);
            }else{
                map1.put(keyM, endM);
            }
            if(endD<10) {
                map1.put(keyD, "[01" + " TO " + "0"+endD + "]");
            }else{
                map1.put(keyD, "[01" + " TO " + endD + "]");
            }
            map1_AND.put("AND",map1);
            list.add(map1_AND);

            if(endM-1>0){
                HashMap<String,Object> map2=new HashMap<>();
                HashMap<String,Object> map2_AND=new HashMap<>();
                //  map2.put(keyY,endY);
                String enM="";
                int enm;
                if(endM-1>=10){
                    enm=endM-1;
                    enM=enm+"";
                }else{
                    enm=endM-1;
                    enM="0"+enm;
                }
                map2.put(keyM,"[01"+" TO "+enM+"]");
                //防止出现生日为无的情况
                map2.put(keyD,"[01 TO 31]");
                map2_AND.put("AND",map2);
                //添加到list
                list.add(map2_AND);
            }

            //   HashMap<String,Object> map3=new HashMap<>();
            //   HashMap<String,Object> map3_AND=new HashMap<>();
            //  map3.put(keyY,"[*"+" TO "+(endY-1)+"]");
            // map3.put(keyM,"[01 TO 12]");
            // map3.put(keyD,"[01 TO 31]");
            //   map3_AND.put("AND",map3);
            //   list.add(map3_AND);

        }else if(!startdate.equals("")&&enddate.equals("")){

            String[] start=startdate.split("-");
            //   int startY=Integer.parseInt(start[0]);
            int startM=Integer.parseInt(start[1]);
            int  startD=Integer.parseInt(start[2]);

            HashMap<String,Object> map1=new HashMap<>();
            HashMap<String,Object> map1_AND=new HashMap<>();
            //  map1.put(keyY,startY);
            if(startM<10) {
                map1.put(keyM, "0"+startM);
            }else{
                map1.put(keyM, startM);
            }
            if(startD<10){
                map1.put(keyD,"["+"0"+startD+" TO "+"31]");
            }else{
                map1.put(keyD,"["+startD+" TO "+"31]");
            }

            map1_AND.put("AND",map1);
            list.add(map1_AND);
            if(12-startM>0){
                HashMap<String,Object> map2=new HashMap<>();
                HashMap<String,Object> map2_AND=new HashMap<>();
                //    map2.put(keyY,startY);
                String stM="";
                int stm;
                if(startM+1>=10){
                    stm=startM+1;
                    stM=stm+"";
                }else{
                    stm=startM+1;
                    stM="0"+stm;
                }
                map2.put(keyM,"["+stM+" TO "+"12]");
                map2.put(keyD,"[01 TO 31]");
                map2_AND.put("AND",map2);
                list.add(map2_AND);
            }
            //       HashMap<String,Object> map3=new HashMap<>();
            //     HashMap<String,Object> map3_AND=new HashMap<>();
            ///  map3.put(keyY,"["+(startY+1)+" TO "+"*]");
            //   map3.put(keyM,"[01 TO 12]");
            //   map3.put(keyD,"[01 TO 31]");
            //   map3_AND.put("AND",map3);
            //   list.add(map3_AND);

        }
        return  list;
    }



    /**
     *
     * 月份相等的情况（生日转换）
     *
     */

    public  static  ArrayList<HashMap<String,Object>> switchBirthDateMequal(String keyY,String keyM,String keyD,String startdate,String enddate){

        //每次调用初始化list
        ArrayList<HashMap<String,Object>> list=new ArrayList<>();
        /**
         *
         * 月份都相等的情况   2014-10-21  >>>>2014-10-29
         *
         */
        String[] start=startdate.split("-");
        String[] end=enddate.split("-");

        //int startBirth=Integer.parseInt(start[1]+start[2]);
        // int endBirth=Integer.parseInt(end[1]+end[2]);
        String startBirth=start[1]+start[2];
        String endBirth=end[1]+end[2];

        //判断生日日期的大小

        if(startBirth.compareTo(endBirth)>0){
            String date="";
            date=startdate;
            startdate=enddate;
            enddate=date;
        }

        String[] startNew=startdate.split("-");
        String[] endNew=enddate.split("-");

        int startM=Integer.parseInt(startNew[1]);
        int  startD=Integer.parseInt(startNew[2]);
        int  endM=Integer.parseInt(endNew[1]);
        int  endD=Integer.parseInt(endNew[2]);

        HashMap<String,Object> map=new HashMap<String, Object>();
        HashMap<String,Object> map_AND=new HashMap<String, Object>();
        // map.put(keyY,startY);
        if(startM<10){
            map.put(keyM,"0"+startM);
        }else{
            map.put(keyM,startM);
        }
        if(startD<10&&endD<10){
            map.put(keyD,"["+"0"+startD+" TO "+"0"+endD+"]");
        }else if(startD<10&&endD>=10){
            map.put(keyD,"["+"0"+startD+" TO "+endD+"]");
        }else if(startD>=10&&endD>=10){
            map.put(keyD,"["+startD+" TO "+endD+"]");
        }
        map_AND.put("AND",map);

        list.add(map_AND);
        return list;
    }





    //用正则表达式判断字符串是否为数字（含负数）
    public static boolean isNumeric(String str) {
        String regEx = "^-?[0-9]+$";
        Pattern pat = Pattern.compile(regEx);
        Matcher mat = pat.matcher(str);
        if (mat.find()) {
            return true;
        }
        else {
            return false;
        }
    }
    //判断是否含有特殊字符
    public  static  boolean isSpecial(String str){
        String regEx = "[`~!@#$%^&*()+=|{}':;',\\\\[\\\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]+";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        if(m.find()){
            return true;
        }else{
            return  false;
        }
    }

}
